home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / tools / czesc_4 / smallmath / source / dpow.a < prev    next >
Text File  |  1993-01-24  |  3KB  |  160 lines

  1.     XDEF _IEEEDPPow
  2.  
  3. ;  Sorry this is such a maze, but I'm not all that experienced with assembly
  4. ;  language (could you tell?). Hopefully the labels are helpful -- I tried to
  5. ;  make them as clear as I could.
  6.  
  7.     SECTION code
  8.  
  9. _IEEEDPPow:
  10.     movem.l     d0-d3,-(sp)
  11.     fmove.d     (sp)+,fp0
  12.     fmove.d     (sp)+,fp1
  13.     ftst.x        fp0
  14.     fbogt.w     ArgPositive
  15.     fbeq.w        ArgEQZero
  16.  
  17. ArgNegative:
  18.     fmove.x     fp3,-(sp)
  19.     fint.x        fp1,fp3
  20.     fcmp.x        fp1,fp3
  21.     fbne.w        ReturnNotANumber
  22. NegativeToIntOrInf:
  23.     ftst.x        fp1
  24.     fmovem.l    fpsr,d0
  25.     btst.l        #25,d0
  26.     bne.w        ReturnNotANumber
  27. NegativeToInteger:
  28.     fmove.x     fp2,-(sp)
  29.     fscale.w    #-1,fp3
  30.     fint.x        fp3,fp2
  31.     fcmp.x        fp3,fp2
  32.     fbeq.w        NegativeToEven
  33. NegativeToOdd:
  34.     fmovem.x    (sp)+,fp2/fp3
  35.     fabs.x        fp0
  36.     flogn.x     fp0
  37.     fmul.x        fp0,fp1
  38.     fetox.x     fp1
  39.     fmove.d     fp1,-(sp)
  40.     movem.l     (sp)+,d0/d1
  41.     bset.l        #31,d0
  42.     rts
  43. NegativeToEven:
  44.     fmovem.x    (sp)+,fp2/fp3
  45.     fabs.x        fp0
  46.     flogn.x     fp0
  47.     fmul.x        fp0,fp1
  48.     fetox.x     fp1
  49.     fmove.d     fp1,-(sp)
  50.     movem.l     (sp)+,d0/d1
  51.     rts
  52.  
  53. ArgPositive:
  54.     flogn.x     fp0
  55.     fmul.x        fp0,fp1
  56.     fetox.x     fp1
  57.     fmove.d     fp1,-(sp)
  58.     movem.l     (sp)+,d0/d1
  59.     rts
  60.  
  61. ArgEQZero:
  62.     ftst.x        fp1
  63. ZeroToZero:
  64.     fbeq.w        ReturnNotANumberNoFP3
  65. ZeroToNonZero:
  66.     fmovem.l    fpsr,d0
  67.     btst.l        #25,d0
  68.     bne.w        ZeroToInfinity
  69. ZeroToReal:
  70.     ftst.x        fp0
  71.     fmovem.l    fpsr,d0
  72.     btst.l        #27,d0
  73.     beq.w        PositiveZeroToReal
  74. NegativeZeroToReal:
  75.     fmove.x     fp3,-(sp)
  76.     fint.x        fp1,fp3
  77.     fcmp.x        fp1,fp3
  78.     fbne.w        ReturnNotANumber
  79. NegativeZeroToInteger:
  80.     ftst.x        fp1
  81.     fmovem.l    fpsr,d0
  82.     btst.l        #25,d0
  83.     bne.w        ReturnNotANumber
  84.     fmove.x     fp2,-(sp)
  85.     fscale.w    #-1,fp3
  86.     fint.x        fp3,fp2
  87.     fcmp.x        fp3,fp2
  88.     fbeq.w        NegativeZeroToEven
  89. NegativeZeroToOdd:
  90.     fmovem.x    (sp)+,fp2/fp3
  91.     ftst.x        fp1
  92.     fbogt.w     NegativeZeroToPositiveOdd
  93. NegativeZeroToNegativeOdd:
  94.     move.l        #$FFF00000,d0
  95.     clr.l        d1
  96.     rts
  97. NegativeZeroToPositiveOdd:
  98.     move.l        #$80000000,d0
  99.     clr.l        d1
  100.     rts
  101. NegativeZeroToEven:
  102.     fmovem.x    (sp)+,fp2/fp3
  103.     ftst.x        fp1
  104.     fbogt.w     NegativeZeroToPositiveEven
  105. NegativeZeroToNegativeEven:
  106.     move.l        #$7FF00000,d0
  107.     clr.l        d1
  108.     rts
  109. NegativeZeroToPositiveEven:
  110.     clr.l        d0
  111.     clr.l        d1
  112.     rts
  113. PositiveZeroToReal:
  114.     ftst.x        fp1
  115.     fbogt.w     PositiveZeroToPositiveReal
  116. PositiveZeroToNegativeReal:
  117.     move.l        #$7FF00000,d0
  118.     clr.l        d1
  119.     rts
  120. PositiveZeroToPositiveReal:
  121.     clr.l        d0
  122.     clr.l        d1
  123.     rts
  124. ZeroToInfinity:
  125.     btst.l        #27,d0
  126.     beq.w        ZeroToPositiveInfinity
  127. ZeroToNegativeInfinity:
  128.     ftst.x        fp0
  129.     fmovem.l    fpsr,d0
  130.     btst.l        #27,d0
  131.     beq.w        PositiveZeroToNegativeInfinity
  132. NegativeZeroToNegativeInfinity:
  133.     bra.w        ReturnNotANumberNoFP3
  134. PositiveZeroToNegativeInfinity:
  135.     move.l        #$7FF00000,d0
  136.     clr.l        d1
  137.     rts
  138. ZeroToPositiveInfinity:
  139.     ftst.x        fp0
  140.     fmovem.l    fpsr,d0
  141.     btst.l        #27,d0
  142.     beq.w        PositiveZeroToPositiveInfinity
  143. NegativeZeroToPositiveInfinity:
  144.     bra.w        ReturnNotANumberNoFP3
  145. PositiveZeroToPositiveInfinity:
  146.     clr.l        d0
  147.     clr.l        d1
  148.     rts
  149.  
  150.  
  151. ReturnNotANumber:
  152.     fmove.x     (sp)+,fp3
  153. ReturnNotANumberNoFP3:
  154.     move.l        #$7FFFFFFF,d0
  155.     move.l        #$FFFFFFFF,d1
  156.     rts
  157.  
  158.     END
  159.  
  160.